<?php
namespace App\Core\Entity\Message;

/**
 * MsgError 错误信息实体对象
 */
class MessageError
{

    private $code = 40000;

    private $message = '';

    private $errors = array();

    public function __construct($code = 40000, $message = '', array $errors = [])
    {
        $this->code = $code;
        $this->message = $message;
        $this->errors = $errors;
    }

    /**
     * 获取错误信息数组对象
     *
     * @return { code : 4001, message : '', errors : [] }
     */
    public function toArray()
    {
        return array(
            'code' => $this->code,
            'message' => $this->message,
            'errors' => $this->errors
        );
    }
}